# import mmcv
import cv2
import os
import json

if __name__ == "__main__":
    data_dir = "/home/HDD/linzihao/datasets/liantong/CPRI/cpri/cpri/all_data"
    img_file = os.path.join(data_dir, "QC-20230927-0020506_1677476832807.jpeg")
    json_file = img_file.replace("jpeg", "json")

    img = cv2.imread(img_file)
    with open(json_file, 'r') as f:
        data = json.load(f)
    bboxes = data["shapes"]

    for bbox in bboxes:
        points = bbox["points"]
        x1, y1 = points[0]
        x2, y2 = points[1]
        img = cv2.rectangle(img, (int(x1), int(y1)), (int(x2), int(y2)), (0, 255, 0), 2)

    cv2.imwrite("vis.png", img)